home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / GSRC208A.ZIP / GEP2.C < prev    next >
C/C++ Source or Header  |  1993-07-07  |  35KB  |  1,131 lines

  1. #include "copyleft.h"
  2.  
  3. /*
  4.     GEPASI - a simulator of metabolic pathways and other dynamical systems
  5.     Copyright (C) 1989, 1992, 1993  Pedro Mendes
  6. */
  7.  
  8. /*************************************/
  9. /*                                   */
  10. /*         GWSIM - Simulation        */
  11. /*        MS-WINDOWS front end       */
  12. /*                                   */
  13. /*       Initialization and some     */
  14. /*           data structures         */
  15. /*                                   */
  16. /*           QuickC/WIN 1.0          */
  17. /*                                   */
  18. /*   (include here compilers that    */
  19. /*   compiled GWSIM successfully)    */
  20. /*                                   */
  21. /*************************************/
  22.  
  23.  
  24. #include <windows.h>
  25. #include <string.h>
  26. #include <float.h>
  27. #include "globals.h"
  28. #include "gaussw.h"
  29. #include "strtbl.h"
  30. #include "simgvar.h"
  31.  
  32. void get_dfts( void );
  33.  
  34. struct kint {
  35.                   unsigned char nconst;
  36.                   unsigned char nmodf;
  37.                   LPSTR descr;
  38.                 LPSTR constnam;
  39.                };
  40.  
  41. struct nodet{
  42.              char item;
  43.              unsigned char val;
  44.              unsigned char left;
  45.              unsigned char right;
  46.             };
  47.  
  48. struct treet{
  49.              struct nodet node[256];
  50.              char id[64][10];
  51.              float constant[32];
  52.              int nnode,
  53.                  nnum,
  54.                  nid,
  55.                  nsub,
  56.                  npro,
  57.                  nmodf,
  58.                  nconst,
  59.                  revers;
  60.              char descr[64];
  61.             };
  62.  
  63. struct opt {
  64.             int dyn;
  65.             long pfo;
  66.             double    endtime;
  67.             double    reltol;
  68.             double    abstol;
  69.             double    hrcz;
  70.             int adams;
  71.             int bdf;
  72.             int ss;
  73.             int debug;
  74.             int txt;
  75.             int structan;
  76.             int staban;
  77.             int stdela;
  78.             int nonela;
  79.             int stdcc;
  80.             int noncc;
  81.             int dat;
  82.             int datsep;
  83.             int datwidth;
  84.             int dattit;
  85.             int datmca;
  86.             int datss;
  87.             int quotes;
  88.             int append;
  89.             char timeu[32];
  90.             char concu[32];
  91.             int scan;
  92.             int scanlog;
  93.             unsigned long scandens;
  94.            };
  95.  
  96. struct plt{
  97.            int type;        /* 0 for 2d, 1 for 3d */
  98.            int file;        /* 0 for dynamics, 1 for steady state */
  99.            int x;            /* column for x */
  100.            int y[10];        /* columns for y */
  101.            int z;            /* column for z */
  102.            int ny;            /* number of y variables */
  103.            int logx;        /* 1 if log x axis */
  104.            int logy;        /* 1 if log y axis */
  105.            int logz;        /* 1 if log z axis */
  106.            int lines;        /* 1 if points connected by lines */
  107.            int colour;        /* 1 if colour to be used */
  108.            int hidden;        /* 1 if hidden line removal */
  109.            int contour;        /* 1 if contour plots on base */
  110.           };
  111.  
  112. struct ou {
  113.            LPSTR title;
  114.            unsigned int idx;
  115.           };
  116.  
  117. struct sp{
  118.           int idx;
  119.           LPSTR title;
  120.           double low;
  121.           double high;
  122.           unsigned long dens;
  123.           int log;
  124.           int lidx;
  125.           int linkedto;
  126.           double factor;
  127.           int operation;
  128.          };
  129.  
  130. GLOBALHANDLE hMetname;                                /* handle to memory block w/ metname    */
  131. GLOBALHANDLE hStepname;                                /* handle to memory block w/ stepname    */
  132. GLOBALHANDLE hStoiu;                                /* handle to memory block w/ stoiu        */
  133. GLOBALHANDLE hSto;                                    /* handle to memory block w/ stoi        */
  134. GLOBALHANDLE hLoop;                                    /* handle to memory block w/ loop        */
  135. GLOBALHANDLE hParams;                                /* handle to memory block w/ params        */
  136. GLOBALHANDLE hKtype;                                /* handle to memory block w/ ktype        */
  137. GLOBALHANDLE hRstr;                                    /* handle to memory block w/ rstr        */
  138. GLOBALHANDLE hOutpEl;                                /* handle to memory block w/ outpel        */
  139. GLOBALHANDLE hStrPool;                                /* handle to memory block w/ strings    */
  140. GLOBALHANDLE hScanPar;                                /* handle to memory block w/ strings    */
  141. GLOBALHANDLE hTree;                                    /* handle to memory block w/ trees        */
  142. GLOBALHANDLE hTreeStr;                                /* handle to memory block w/ tree str    */
  143. GLOBALHANDLE hTmpF;                                    /* handle to memory block w/ temp files    */
  144.  
  145. char    (huge *metname)[NAME_L];                    /* pointer to work with metname array    */
  146. char    (huge *stepname)[NAME_L];                    /* metabolite names                        */
  147. int        huge *stoiu;                                /* pointer to work with stoiu array        */
  148. int        huge *stoi;                                    /* pointer to work with stoi array        */
  149. unsigned char (huge *loop)[MAX_STEP][MAX_MET];        /* def. of modification loops            */
  150. int        (huge *rstr)[MAX_STEP][MAX_MOL];            /* reaction structure                    */
  151. char    topname[256];                                /* title for the topology                */
  152. char    stepstr[MAX_STEP][256];                        /* array to hold description of steps    */
  153. double     huge *params[MAX_STEP];                        /* ptr to parameters for each rate eq.    */
  154. DWORD    sizeparam;                                    /* size of parameters memory block        */
  155. DWORD    sizeoutp;                                    /* size of outpel memory block            */
  156. DWORD    sizestrp;                                    /* size of StrPool memory block            */
  157. DWORD    sizestra;                                    /* size of allocated strings in StrPool    */
  158. DWORD    sizespar;
  159. DWORD    sizetr;                                        /* size of allocated strings in TreeStr    */
  160. double    xu[MAX_MET];                                /* metabolite concentrations            */
  161. double    moiety[MAX_MET];                            /* concentration of conserved moieties    */
  162. int        intmet[MAX_MET];                            /* 1 if internal metabolite                */
  163. unsigned char    revers[MAX_STEP];                    /* 1 if reaction is reversible            */
  164. int        kinetu[MAX_STEP];                            /* type of kinetics (user numb.)        */
  165. int        kfl[MAX_STEP];                                /* flags for input of user-def.kinetics */
  166. LPSTR    strpool;                                    /* points to the string pool mem block    */
  167. LPSTR    treestr;                                    /* points to the tree string pool        */
  168. LPSTR    treeptr;                                    /* points to the tree string pool        */
  169. struct    opt options;                                /* structure with simulation options    */
  170. struct    plt plot;                                    /* structure with plot options            */
  171. struct    kint huge *ktype;                            /* ptr array of kinetic types & proprt    */
  172. struct    ou huge *outpel;                            /* ptr array of output elements            */
  173. struct    sp huge *spar;                                /* ptr array of scanning elements        */
  174. float    ver_no;                                        /* .top and .sim version number            */
  175. double    dft_endtime;                                /* time value for last iteration        */
  176. double    dft_hrcz;                                    /* highest rate considered zero            */
  177. int        totmet;                                        /* number of total metabolites            */
  178. int        nmetab;                                        /* number of internal metabolites        */
  179. int        indmet;                                        /* number of independent metabolites    */
  180. int        nextmet;                                    /* number of external metabolites        */
  181. int        nsteps;                                        /* number of steps                        */
  182. int        nloops;                                        /* number of modifier loops             */
  183. int        noutpel;                                    /* number of output elements            */
  184. int        nudf;                                        /* number of user-defined functions        */
  185. int        nrateq;                                        /* number of user-defined functions        */
  186. int        totsel;                                     /* number of selected output elements    */
  187. int        totscan;                                    /* number of dimensions to scan            */
  188. int        nscanpar;                                   /* number of scanning elements            */
  189. int        nlinks;                                        /* number of links between parameters    */
  190. unsigned char dft_debugval;                            /* debug mode                            */
  191. double    dft_conc;                                    /* default metabolite concentration        */
  192. double    dft_const;                                    /* default value for kinetic constants    */
  193. char    *dft_timeu;                                    /* default time units                    */
  194. char    *dft_concu;                                    /* default conctration units            */
  195. unsigned long dft_pfo;                                /* number of points for output            */
  196. struct    treet huge *tree;                            /* function tree for rate equations        */
  197. struct    treet tr;                                    /* tree for the input                    */
  198. LPSTR    TmpFiles;                                    /* string holding names of temp files    */
  199.  
  200. int        InitGepasiVar( void );
  201. void    TidyGepasiVar( void );
  202. int     SetParams( void );
  203. int     SetOutpEl( void );
  204. void     step_string( void );
  205. void    conc_dft( void );
  206. void     numer_dft( void );
  207. void     def_def( void );
  208. void     set_dfts( void );
  209. void     get_dfts( void );
  210.  
  211. #pragma alloc_text( CODE1, InitGepasiVar, TidyGepasiV